package com.huishu.coupon.controller;


import com.huishu.commons.pojo.Result;
import com.huishu.commons.pojo.dto.ReturnUserCouponDTO;
import com.huishu.commons.pojo.dto.UseCouponDTO;
import com.huishu.coupon.service.CouponHistoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author generator@ljj
 * @since 2023-04-10
 */
@RestController
@RequestMapping("/coupon-history")
@Slf4j
public class CouponHistoryController {

    @Autowired
    private CouponHistoryService couponHistoryService;


    @PostMapping("/use-coupon")
    public Result useCoupon(@RequestBody List<UseCouponDTO> useCoupons) {
        return couponHistoryService.useCoupon(useCoupons);
    }

    @GetMapping("/my-coupon/{type}")
    public Result myCoupon(@PathVariable Integer type) {
        return couponHistoryService.myCoupon(type);
    }

    @GetMapping("/draw/{couponId}")
    public Result draw(@PathVariable Long couponId) {
        return couponHistoryService.draw(couponId);
    }

    @PostMapping("/return-user-coupon")
    public Result returnUserCoupon(@RequestBody ReturnUserCouponDTO returnUserCouponDTO) {
        return couponHistoryService.returnUserCoupon(returnUserCouponDTO);
    }

    @GetMapping("/draw-community/{couponId}")
    public Result drawCommunity(@PathVariable Long couponId) {
        // return couponHistoryService.drawCommunity(couponId);
        return null;
    }

    @GetMapping("/receive-association/{couponId}/{code}")
    public Result receiveAssociation(@PathVariable Long couponId, @PathVariable String code) {
        return couponHistoryService.receiveAssociation(couponId, code);
    }

    @GetMapping("/sendReceiveAssociationCoupon/{openId}/{userId}")
    public Result sendReceiveAssociationCoupon(@PathVariable String openId,@PathVariable Long userId){
        return couponHistoryService.sendReceiveAssociationCoupon(openId,userId);
    }
}
